<template>
  <div>
    <div class="table-data" v-show="tabShow">
      <div class="search-box">
        <el-input size="small" v-model="searchData.type" placeholder="渠道名称"></el-input>
        <el-button size="small" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
      </div>
      <el-table :data="tableData" :header-cell-style="headClass" style="width:100%" :height="tHeight" class="table-box">
        <el-table-column label="序号" width="120" prop="location"></el-table-column>
        <el-table-column label="渠道名称"  prop="applicationName"></el-table-column>
        <el-table-column label="请求ip" prop="type"></el-table-column>
        <el-table-column label="请求数据" prop="client"></el-table-column>
        <el-table-column label="响应数据" prop="versions"></el-table-column>
        <el-table-column label="请求路径" prop="state"></el-table-column>
        <el-table-column label="创建时间" prop="channelNames"></el-table-column>
      </el-table>
      <div class="pages" ref="page-box">
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10,30,50]"
        :page-size="searchData2.pageSize"
        layout="total,sizes,prev,pager,next,jumper"
        :total="total"
      ></el-pagination>
      </div>
    </div>
    <router-view @loadData="loadData" :tabShow="tabShow"></router-view>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Provide,Prop,Watch } from "vue-property-decorator";
// import { State, Getter, Mutation, Action } from "vuex-class";
@Component({
  components: { }
})
export default class channelList extends Vue {
  // @Getter("user") getUser: any;
  @Provide() state: string = "1"; // 状态默认值
  @Provide() tHeight: number = document.body.offsetHeight - 323;
  @Provide() tableData: any = []; // 表格数据
  @Provide() page: number = 1; // 当前page
  @Provide() size: number = 10; // 请求数据的个数 默认5
  @Provide() total: number = 0; // 总数据条数
  @Provide() tabShow: Boolean = true; // 是显示否列表页面
  @Prop({}) tabVisible!: any;
  @Provide() searchData:{
    location: string,
    type: string,
    versions: string,
    state:string,
  }={
    location: "",
    type: "",
    versions: "",
    state:""
  }
  @Provide() searchData2:{
    location: string,
    type: string,
    versions: string,
    state:string,
    pageNum:number,
    pageSize:number 
  }={
    location: "",
    type: "",
    versions: "",
    state:"",
    pageNum:1,
    pageSize:10 
  }
  @Watch("$route") handleRouteChange(to: any,form:any) {
    if(form.path!='/channelList'){
      this.tabShow=this.tabVisible;
    }
  }
  headClass() {
    return "text-align: center;background:#eef1f6;";
  }
  @Provide() searchDatas:{// 查询渠道参数
    market:string,
    channelNo: string,

  }={
    market:"",
    channelNo: "",
  }
  // 新增
  handleAdd(){
    this.tabShow=false
    this.$router.push({
      path:'/channelList/add'
    })
  }
  // 编辑
  handleEdit(index: number, row: any){
    this.tabShow=false
  }
  // 删除
  handleDelete(index: number, row: any) {
    
  }
  created() {
    // this.loadData();
    if(this.$route.path!='/channelList'){
      this.tabShow=false
    }
  }

  loadData() {
    
  }

  handleSizeChange(val: number): void {
    this.searchData2.pageSize = val;
    this.searchData2.pageNum = 1;
    this.loadData();
  }

  handleCurrentChange(val: number): void {
    this.searchData2.pageNum = val;
    this.loadData();
  }

  handleSearch(): void {
    // 点击搜索
  this.searchData2.pageNum = 1;
  this.loadData();
  }
}
</script>

<style lang="scss" scoped>
.el-date-editor{
  margin-right: 10px;
}
</style>
